﻿/****************************************************************************************************
	警告！！
	このソースコードは自動生成されたものです
	このファイルを直接編集すると、編集した内容が失われる可能性があります
*****************************************************************************************************/
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Sales
{
	class Result : INotifyPropertyChanged
	{
		private readonly ValidationContext _validationContext;
		public event PropertyChangedEventHandler PropertyChanged;

		public Result()
		{
			_validationContext = new ValidationContext(this, null, null);
			Id = 0;
			Date = DateTime.Today;
			SectionId = 1;
			Client = string.Empty;
			Title = string.Empty;
			Price = 0;
		}

		protected virtual void RaisePropertyChanged(string propertyName)
		{
			if (PropertyChanged == null) return;
			PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}

		private int _id;
			
		public int Id
		{
			get
			{
				return _id;
			}
			set
			{
				if (_id == value) return;
				_validationContext.MemberName = "Id";
				Validator.ValidateProperty(value, _validationContext);
				_id = value;
				RaisePropertyChanged("Id");
			}
		} 

		private DateTime _date;
			
		public DateTime Date
		{
			get
			{
				return _date;
			}
			set
			{
				if (_date == value) return;
				_validationContext.MemberName = "Date";
				Validator.ValidateProperty(value, _validationContext);
				_date = value;
				RaisePropertyChanged("Date");
			}
		} 

		private byte _sectionid;
		[Range(1, byte.MaxValue, ErrorMessage=@"設定可能な値の範囲外です")]	
		public byte SectionId
		{
			get
			{
				return _sectionid;
			}
			set
			{
				if (_sectionid == value) return;
				_validationContext.MemberName = "SectionId";
				Validator.ValidateProperty(value, _validationContext);
				_sectionid = value;
				RaisePropertyChanged("SectionId");
			}
		} 

		private string _client;
		[StringLength(32, ErrorMessage=@"32文字以内で設定してください")]	
		public string Client
		{
			get
			{
				return _client;
			}
			set
			{
				if (_client == value) return;
				_validationContext.MemberName = "Client";
				Validator.ValidateProperty(value, _validationContext);
				_client = value;
				RaisePropertyChanged("Client");
			}
		} 

		private string _title;
		[StringLength(32, ErrorMessage=@"32文字以内で設定してください")]	
		public string Title
		{
			get
			{
				return _title;
			}
			set
			{
				if (_title == value) return;
				_validationContext.MemberName = "Title";
				Validator.ValidateProperty(value, _validationContext);
				_title = value;
				RaisePropertyChanged("Title");
			}
		} 

		private int _price;
		[Range(0, 99999999, ErrorMessage=@"設定可能な値の範囲外です")]	
		public int Price
		{
			get
			{
				return _price;
			}
			set
			{
				if (_price == value) return;
				_validationContext.MemberName = "Price";
				Validator.ValidateProperty(value, _validationContext);
				_price = value;
				RaisePropertyChanged("Price");
			}
		} 

		public void SetProperties(Result source)
		{
			Id = source.Id;
			Date = source.Date;
			SectionId = source.SectionId;
			Client = source.Client;
			Title = source.Title;
			Price = source.Price;
		}
	}
}
